home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1987 August
/
1987-08.d64
/
relative files
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
2KB
|
73 lines
10 rem copyright 1987 compute! publications inc. - all rights reserved
20 print"[147] copyright 1987 compute! pub., inc."
30 printtab(9)"all rights reserved"
40 open 15,8,15
50 open 1,8,2,"0:testrel"
60 input#15,e,e$,e1,e2
70 if e=0 goto230
80 close 1
90 if e<>62 then print e;e$;e1;e2:stop
100 print"creating file"
110 open 1,8,2,"0:testrel,l,"+chr$(33)
120 input#15,e,e$,e1,e2
130 if e<>0 then close 1:print e,e$,e1,e2:stop
140 print#15,"p"+chr$(98)+chr$(10)+chr$(0)+chr$(1)
150 input#15,e,e$,e1,e2
160 if e<>50 then close 1:print e;e$;e1;e2:stop
170 print#1,chr$(255);
180 input#15,e,e$,e1,e2
190 close 1
200 if e<>0 then print e;e$;e1;e2:stop
210 open 1,8,2,"0:testrel"
220 goto240
230 print"file already exists"
240 print"1. read all records"
250 print"2. write record"
260 print"3. quit"
270 input"which (1, 2 or 3)";x:print
280 on x goto300,440,710
290 goto240
300 r=0
310 r=r+1:f=0:x=0
320 h=int(r/256):l=r-h*256
330 print#15,"p"+chr$(98)+chr$(l)+chr$(h)+chr$(1)
340 input#15,e,e$,e1,e2
350 if e=50 goto240
360 if e<>0 then print e;e$;e1;e2:goto710
370 input#1,x$:sw=st
380 if x$=chr$(255) then print"record";r;"<empty>":goto310
390 if f=0 then print"record";r;":"
400 f=f+1:if sw=0 then x=1
410 print" field";f;": ";x$
420 if sw=0 goto370
430 goto310
440 input"write to record number";r
450 if r<1 or r<>int(r) goto440
460 if r>40 then print "too big!":goto570
470 h=int(r/256):l=r-h*256
480 print#15,"p"+chr$(98)+chr$(l)+chr$(h)+chr$(1)
490 input#15,e,e$,e1,e2
500 if e=50 then print"a new one!"
510 input"how many fields (1-3)";n
520 if n<1 or n>3 goto510
530 a$=""
540 print"enter data:"
550 for j=1 to n
560 if n<>1 then print"field";j;
570 input b$
580 a$=a$+b$+chr$(13)
590 next j
600 a$=left$(a$,len(a$)-1)
610 print#1,a$;
620 input#15,e,e$,e1,e2
630 if e<>0 then print e;e$;e1;e2
640 close 1
650 input#15,e,e$,e1,e2
660 if e<>0 then print e;e$;e1;e2
670 open 1,8,2,"0:testrel"
680 input#15,e,e$,e1,e2
690 if e<>0 then print e;e$;e1;e2
700 goto240
710 close 1
720 close 15